package file.tcp;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Client {

	public static void main(String[] args) throws UnknownHostException, IOException {
		// TODO Auto-generated method stub
		Socket socket=new Socket("127.0.0.1",8887);
		OutputStream os=socket.getOutputStream();
		InputStream is=socket.getInputStream();
		BufferedReader bufR=new BufferedReader(new InputStreamReader(is));
		System.out.println(bufR.readLine());
		String output=""; //
		String input="";  //read file server commmit
		Scanner sc=new Scanner(System.in);
//		while(sc.hasNext())
//		{
//			 output=sc.nextLine();
//			 os.write((output+"\n").getBytes());
//			 while((input=bufR.readLine())!=null)
//			 {
//				 int flag=0;
//				 if(input.startsWith("file found")||flag==1)
//				 {
//					 flag=1;
//					 OutputStream fileOutput = new FileOutputStream("copy.txt");
//					 while((input=bufR.readLine())!=null)
//					 {
//						 System.out.println(input);
//						 if(input.equals("file end"))
//							 break;
//						 fileOutput.write(input.getBytes());
//						 fileOutput.write("\n".getBytes());
//					 }
//				 }
//				 else
//				 {
//					 System.out.println("the file you want not found ! Correct the name or path and input what you want");
//				 }
//				 break;
//			 }
//		}
		String s=sc.nextLine();
		InputStream in=new FileInputStream(s);
		
		os.close();
		bufR.close();
		
	}

}
